<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var arr = [1,3,5,7,9,10,20,12];
        var newArr = [];
        // 循环
        arr.forEach(function(val,index,arr){
            if(val%2==0){
                newArr.push(val);
            }
        });
        console.log(newArr);
        console.log('ES5............');
        // 最终返回新的数组
        var esArr = arr.filter(function(val,index,arr){
            return val%2 == 0;


        });
        console.log(esArr);
    </script>
</body>
</html>